package com.shareach.domain;

import java.util.Arrays;
import java.util.Date;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;
import com.shareach.domain.common.Sites;

/**
 * 商家
 * 
 * @author zuoshuaiok@gmail.com
 * 
 *         2013-1-28
 */
@Document(collection = "baseShop")
public class BaseShopDomain extends Entity {
	// /分店名
	private String name;
	// 品牌名标识【参见 品牌】
	private String brand;
	// 和baseBrand的id关联
	private Long brandId;
	// 别名
	private String[] alias;
	// 地址
	private String addr;
	// 电话
	private String[] tels;
	// 坐标
	private Double[] loc;
	// 城市【参见 城市BaseCity】
	private Long city;
	// 分类Id【参见 商家类别BaseCategory】
	private Long category;
	// 子分类 多个
	private Long[] subCategory;
	// 价格
	private Integer price;
	// 指数
	private Integer rate;
	// 标签
	private String[] tags;
	// 城区
	private String region;
	// /商圈【以百度商圈为准】
	private Long[] zoom;
	private String weiboId;
	private String[] weiboIds;
	// 参见 来源网站 BaseSite
	private Set<Sites> sites;
	// 状态【0正常，1未启用，-1删除】
	private Integer status;
	private String time;// 营业时间
	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;

	private String img;

	public String getAddr() {
		return addr;
	}

	public String[] getAlias() {
		return alias;
	}

	public String getBrand() {
		return brand;
	}

	public Long getBrandId() {
		return brandId;
	}

	public Long getCategory() {
		return category;
	}

	public Long getCity() {
		return city;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public String getImg() {
		return img;
	}

	public Double[] getLoc() {
		return loc;
	}

	public String getName() {
		return name;
	}

	public Integer getPrice() {
		return price;
	}

	public Integer getRate() {
		return rate;
	}

	public String getRegion() {
		return region;
	}

	public Set<Sites> getSites() {
		return sites;
	}

	public Integer getStatus() {
		return status;
	}

	public Long[] getSubCategory() {
		return subCategory;
	}

	public String[] getTags() {
		return tags;
	}

	public String[] getTels() {
		return tels;
	}

	public String getTime() {
		return time;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public Long[] getZoom() {
		return zoom;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public void setAlias(String[] alias) {
		this.alias = alias;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public void setBrandId(Long brandId) {
		this.brandId = brandId;
	}

	public void setCategory(Long category) {
		this.category = category;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public void setLoc(Double[] loc) {
		this.loc = loc;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	public void setRate(Integer rate) {
		this.rate = rate;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getWeiboId() {
		return weiboId;
	}

	public void setWeiboId(String weiboId) {
		this.weiboId = weiboId;
	}

	public String[] getWeiboIds() {
		return weiboIds;
	}

	public void setWeiboIds(String[] weiboIds) {
		this.weiboIds = weiboIds;
	}

	public void setSites(Set<Sites> sites) {
		this.sites = sites;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public void setSubCategory(Long[] subCategory) {
		this.subCategory = subCategory;
	}

	public void setTags(String[] tags) {
		this.tags = tags;
	}

	public void setTels(String[] tels) {
		this.tels = tels;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public void setZoom(Long[] zoom) {
		this.zoom = zoom;
	}

	public BaseShopDomain compareTo(BaseShopDomain domain) {
		BaseShopDomain change = new BaseShopDomain();
		if (domain == null)
			return change;
		if (StringUtils.isNotEmpty(domain.getAddr())) {
			if (this.addr == null || !this.addr.trim().equals(domain.getAddr().trim())) {
				change.setAddr(domain.getAddr().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getBrand())) {
			if (this.brand == null || !this.brand.trim().equals(domain.getBrand().trim())) {
				change.setBrand(domain.getBrand().trim());
			}
		}

		if (domain.getBrandId() != null) {
			if (this.brandId == null || !this.brandId.equals(domain.getBrandId())) {
				change.setBrandId(domain.getBrandId());
			}
		}

		if (StringUtils.isNotEmpty(domain.getImg())) {
			if (this.img == null || !this.img.trim().equals(domain.getImg().trim())) {
				change.setImg(domain.getImg());
			}
		}

		if (domain.getCategory() != null) {
			if (this.category == null || !this.category.equals(domain.getCategory())) {
				change.setCategory(domain.getCategory());
			}
		}
		if (domain.getCity() != null) {
			if (this.city == null || !this.city.equals(domain.getCity())) {
				change.setCity(domain.getCity());
			}
		}

		if (domain.getPrice() != null) {
			if (this.price == null || !this.price.equals(domain.getPrice())) {
				change.setPrice(domain.getPrice());
			}
		}

		if (domain.getRate() != null) {
			if (this.rate == null || !this.rate.equals(domain.getRate())) {
				change.setRate(domain.getRate());
			}
		}

		if (StringUtils.isNotEmpty(domain.getRegion())) {
			if (this.region == null || !this.region.trim().equals(domain.getRegion().trim())) {
				change.setRegion(domain.getRegion());
			}

			if (domain.getSubCategory() != null && domain.getSubCategory().length > 0) {
				if (this.subCategory == null || !Arrays.equals(this.subCategory, domain.getSubCategory())) {
					change.setSubCategory(domain.getSubCategory());
				}
			}

			if (domain.getTags() != null && domain.getTags().length > 0) {
				if (this.tags == null || !Arrays.equals(this.tags, domain.getTags())) {
					change.setTags(domain.getTags());
				}
			}

			if (domain.getTels() != null && domain.getTels().length > 0) {
				if (this.tels == null || !Arrays.equals(this.tels, domain.getTels())) {
					change.setTels(domain.getTels());
				}
			}

			if (domain.getZoom() != null && domain.getZoom().length > 0) {
				if (this.zoom == null || !Arrays.equals(this.zoom, domain.getZoom())) {
					change.setZoom(domain.getZoom());
				}
			}

			if (StringUtils.isNotEmpty(domain.getName())) {
				if (null == this.name || !this.name.trim().equals(domain.getName())) {
					change.setName(domain.getName());
				}
			}
		}
		if (domain.getStatus() != null) {
			if (null == this.status || !this.status.equals(domain.getStatus())) {
				change.setStatus(domain.getStatus());
			}
		}
		return change;
	}

}
